This Extension enables you to compile in the background using THINK C 5.0 or 4.0.5 under System 7.0. If THINK C finishes compiling while it's in the background, the Notification Manager will be used to tell you that it's done.
Installation and Use
Drop THINK Back in your Extensions folder and restart. To start a backgroundable compile, hold down the shift key when choosing any THINK C action that will cause a source file to be compiled. THINK Back will change the compiler's progress dialog to a movable modal dialog box if it's active. For example, if you bring up the Make dialog box and hold down the shift key while clicking on the Make button, THINK Back will be activated. It will also be activated if you press command-shift-U instead of just command-U (Bring up to date). You can use command-period to cancel a compile as usual. THINK Back will refuse to install itself if any of its needed resources are missing, or if you try to use it under System 6.
Customizing
There's no Control Panel interface for this yet, so you'll have to use ResEdit if you want to customize THINK Back's behavior. You can edit the PREF resource using the template provided. You can change:
• The number of ticks that THINK C passes to WaitNextEvent when it's in the
foreground or background. Using this, you can fine-tune it's performance on
your machine. The default settings (5 ticks in the foreground, 15 in the
background) should provide good performance on a IIsi.
• If THINK Back is on or off by default. If it's on by default, then you can
disable it by holding down the shift key when starting a compile. If it's off
by default, then THINK Back will not be activated unless you hold down the
shift key when starting a compile. The default setting is off by default.
• The "level" of notification. There are four settings:
0 - no notification at all
1 - mark THINK C in the application menu with a diamond
2 - mark THINK C and display a rotating THINK C icon in the Application menu
3 - mark THINK C, display a rotating icon, and present an alert letting you know
that C is finished compiling
The default setting is level 2.
If you change the PREF resource, changes will take effect the next time you boot your Macintosh.
How it works
At INIT time, THINK Back installs a global head patch on the _GetNewDialog trap. This trap watches each call to GetNewDialog and looks for the THINK C Progress dialog box. When it sees this dialog, it installs a number of other patches local to THINK C, one of which calls WaitNextEvent. When the compile is finished, all of the installed patches are removed (except the one on _GetNewDialog). The code is loaded low in the System heap, and it plus its data take up less than 2K.
Bugs/Odd Features
Since the same dialog is used for different things in THINK C, this patch will also background Multi-File Search, Precompile, Check Syntax, Disassemble and Preprocess -- this should not cause any problems, but these "features" have not been tested.
If THINK Back causes a "hang" when you bring THINK C to the front, you can safely use a low-level debugger to perform an ExitToShell on THINK C's heap. This should not damage your project. After doing this, you will need to reboot to use THINK Back again. The problem that caused 1.0 to hang has been found, and you shouldn't have any problems with later versions hanging.
Credits
ShowIconFamily by Patrick C. Beard
StartupError by joe holt
Version History
1.0.1 - calls WaitNextEvent less often when THINK C is in the foreground. When
it's placed in the background, WaitNextEvent is called as often as before.
- disallows reentrant use (you can't background two compiles at the same time)
- disables CMaster's menu (if present) during compiles
- uses a much more reliable method to tell if THINK C is in the background or
not. This fixes the bug where THINK C would hang after switching it in & out.
- multi-file searches are backgroundable now as well.
1.0 - finalized 12/18/91; identical to version 1.0b4
Future enhancements
• Use the Time Manager to regulate how much CPU time THINK C takes up
• Save the Progress window's position between compiles and between launches
• Custom sound when a compile is finished
• Customize toggle key modifiers
• Control Panel interface for preferences
• Implement same idea for THINK Pascal
Please contact me if you find any bugs, or have any suggestions for improvement. Thanks for all the positive feedback that I've gotten!